# Stage 1: build
FROM golang:1.13 AS builder

ENV GOPROXY=https://goproxy.cn,direct
ARG PROJECT_PATH=gitee.com/sqxwww/deploy_demo

RUN mkdir -p /build/$PROJECT_PATH
WORKDIR /build/$PROJECT_PATH
COPY . .

RUN CGO_ENABLED=0 go build -o /deploy ./main


# Stage 2: minimize
FROM scratch
ENV TZ=Asia/Shanghai
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /deploy .

ENTRYPOINT ["./deploy"]
